﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RPGMapRevealer
{
    public partial class LightAdjustDialog : Form
    {
        public LightAdjustDialog()
        {
            InitializeComponent();
        }

        public int Value
        {
            get { return numvalue; }
            set
            {
                numvalue = Math.Max(MinValue, Math.Min(MaxValue, value));
                textBox1.Text = value.ToString();
            }
        }
        private int numvalue;

        private int minvalue = 1;
        private int maxvalue = 100;

        public int MinValue
        {
            get { return minvalue; }
            set 
            {
                minvalue = value;
                if (value > maxvalue)
                { maxvalue = value; }
                Value = Value;
            }
        }

        public int MaxValue
        {
            get { return maxvalue; }
            set
            {
                maxvalue = value;
                if (value < minvalue)
                { minvalue = value; }
                Value = Value;
            }
        }

        private void buttonDecrease_Click(object sender, EventArgs e)
        { Value--; }

        private void buttonIncrease_Click(object sender, EventArgs e)
        { Value++; }

        private void textBoxValue_TextChanged(object sender, EventArgs e)
        {
            int num;
            if (Int32.TryParse(textBox1.Text, out num))
            { Value = num; }
            else
            { textBox1.Text = Value.ToString(); }
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
